package com.gitee.wsl.math

import com.gitee.wsl.mathematics.function.noise.Perlin
import kotlin.math.absoluteValue


object Noise {
    /**
     * Generates perlin noise value in 1D for given x offset.
     * Linear sequence of noise values in a one-dimensional space, and we can ask for a value at a specific x-location whenever we want.
     *
     * @param [x] x offset on plane.
     * @return The value of noise at specific x location
     */
    fun noise1D(x: Double): Double {
        return Perlin.noise(x, 0.0, 0.0).absoluteValue
    }

    /**
     * Generates perlin noise values for 2D for given x and y offset
     *
     * @param [x] [y] x and y offset
     * @return The perlin noise value at x and y location at given point it time
     */
    fun noise2D(x: Double, y: Double): Double {
        return Perlin.noise(x, y, 0.0).absoluteValue
    }

    /**
     * Generates perlin noise values for 3D
     *
     * @param [x] [y] [z] x, y & z offset
     * @return The perlin noise value at (x, y, z) location at given point it time
     */
    fun noise3D(x: Double, y: Double, z: Double): Double {
        return Perlin.noise(x, y, z).absoluteValue
    }
}

